package yaner.hotel.manager.resource.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import yaner.hotel.manager.common.dto.order.OrderAddDto;
import yaner.hotel.manager.common.dto.order.OrderDto;
import yaner.hotel.manager.common.dto.order.OrderUpdateDto;
import yaner.hotel.manager.common.vo.OrderVo;
import yaner.hotel.manager.common.vo.ResponseVo;
import yaner.hotel.manager.resource.service.IOrderService;

import java.util.List;

/**
 * @Author kf-leig
 * @Description: 订单管理
 * @Version 1.0
 * @Date 2024年05月22日11:31:00
 */
@RestController
public class OrderController {
    @Autowired
    private IOrderService orderService;
    @PostMapping("/order-list")
    public ResponseVo<List<OrderVo>> list(@RequestBody OrderDto orderDto) {
        List<OrderVo> orderVos = orderService.orderList(orderDto);
        return ResponseVo.success(orderVos);
    }

    @GetMapping("/get-order-info")
    public ResponseVo<OrderVo> getOrderInfo(@RequestParam("orderId") String orderId) {
        OrderVo orderInfo = orderService.getOrderInfo(orderId);
        return ResponseVo.success(orderInfo);
    }

    @GetMapping("/generate-order-code")
    public ResponseVo<String> generateOrderCode() {
        String generateOrderCode = orderService.generateOrderCode();
        return ResponseVo.success(generateOrderCode);
    }

    @PostMapping("/add-order-info")
    public ResponseVo<String> addOrderInfo(@RequestBody OrderAddDto orderAddDto) {
        String addOrderInfo = orderService.addOrderInfo(orderAddDto);
        return ResponseVo.success(addOrderInfo);
    }

    @PostMapping("/update-order-info")
    public ResponseVo<String> updateOrderInfo(@RequestBody OrderUpdateDto orderUpdateDto) {
        String updateOrderInfo = orderService.updateOrderInfo(orderUpdateDto);
        return ResponseVo.success(updateOrderInfo);
    }

    @DeleteMapping("/delete-order-info")
    public ResponseVo<String> deleteOrderInfo(@RequestParam("orderId") String orderId) {
        String deleteOrderInfo = orderService.deleteOrderInfo(orderId);
        return ResponseVo.success(deleteOrderInfo);
    }
}
